import com.itFox.dao.studentMapper;
import com.itFox.pojo.student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

public class testFind {
    studentMapper sm;
    {
        String resource = "config-mybatis.xml";
        InputStream is;
        try {
            is = Resources.getResourceAsStream(resource);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(is);
        SqlSession ss = ssf.openSession(true);

        sm = ss.getMapper(studentMapper.class);
    }

    @Test
    public void testInsert() {
        sm.insert();
    }

    @Test
    public void testSelect(){
        student[] select = sm.select();
        for (student student : select) {
            System.out.println(student);
        }
    }
}
